package zcw.com.lib_leet_code;

/**
 * Created by 朱城委 on 2021/8/26.<br><br>
 *
 * 中等：不同路径
 */
public class Topic62 {

    public static void main(String[] args) {
        Topic62 instance = new Topic62();

        System.out.println(instance.uniquePaths(3, 7));
        System.out.println(instance.uniquePaths(7, 3));
        System.out.println(instance.uniquePaths(3, 2));
        System.out.println(instance.uniquePaths(3, 3));
    }

    public int uniquePaths(int m, int n) {
        int[][] map = new int[m][n];

        for(int i = 0; i < m; i++) {
            map[i][0] = 1;
        }

        for(int i = 0; i < n; i++) {
            map[0][i] = 1;
        }

        for(int i = 1; i < m; i++) {
            for(int j = 1; j < n; j++) {
                map[i][j] = map[i - 1][j] + map[i][j - 1];
            }
        }

        return map[m - 1][n - 1];
    }
}
